package com.dxy.multids.controller;

import com.dxy.multids.pojo.UserInfo;
import com.dxy.multids.service.UserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/multids/user")
public class UserInfoController {

    @Autowired
    private UserInfoService userInfoService;

    @PostMapping("/add")
    private UserInfo add(String name) {
        UserInfo user = new UserInfo();
        user.setName(name);
        userInfoService.save(user);
        return user;
    }

    @GetMapping("getById")
    private UserInfo getById(Long id) {
        return userInfoService.getById(id);
    }

    @GetMapping("getUserAndTask")
    public Map<String, Object> getUserAndTask(Long userId, Long taskId) {
        return userInfoService.getUserAndTask(userId, taskId);
    }
}
